
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>展示所有图书</title>
    <style type="text/css">
        .active{
            background-color: yellow;
        }
    </style>
</head>
<body>
    <h3>用户登录</h3>
<form action="loginout" method="post" enctype="application/x-www-form-urlencoded">
    <input type="submit" value="登出"/>
</form>
      <h3>书籍列表</h3>
      <a href="addbook.html">添加图书</a>

      <table width="90%" border="1"  style="margin: 0px auto">
          <tr>
              <th>编号</th>
              <th>书名</th>
              <th>作者</th>
              <th>价格</th>
              <th>操作</th>
          </tr>
          <c:forEach items="${pageBean.data}" var="book">
              <tr>
                  <td>${book.id}</td>
                  <td>${book.title}</td>
                  <td>${book.author}</td>
                  <td>${book.price}</td>

                  <td>
                      <c:url var="updateurl" value="updateui">
                          <c:param name="id" value="${book.id}"></c:param>
                      </c:url>
                      <a href="${updateurl}">更新</a>
                      <c:url var="deleteurl" value="deletebook">
                          <c:param name="id" value="${book.id}"></c:param>
                      </c:url>
                      <a onclick="return confirm('确定要删除吗?')" href="${deleteurl}">删除</a>
                  </td>
              </tr>
          </c:forEach>
      </table>
      <div style="width: 90%; margin: 0px auto;">
          <a href="${pageContext.request.contextPath}/booklistpage?pageNum=1&pageSize=${pageBean.pageSize}&title=${title}&author=${author}">首页</a>
          <a href="${pageContext.request.contextPath}/booklistpage?pageNum=${pageBean.pageNum-1}&pageSize=${pageBean.pageSize}&title=${title}&author=${author}">上一页</a>
          <c:forEach var="num" begin="${pageBean.startPage}" end="${pageBean.endPage}">
              <c:if test="${pageBean.pageNum==num}">
                  <a class="active" href="${pageContext.request.contextPath}/booklistpage?pageNum=${num}&pageSize=${pageBean.pageSize}&title=${title}&author=${author}">${num}</a>
              </c:if>
             <c:if test="${pageBean.pageNum!=num}">
                 <a href="${pageContext.request.contextPath}/booklistpage?pageNum=${num}&pageSize=${pageBean.pageSize}&title=${title}&author=${author}">${num}</a>
             </c:if>
          </c:forEach>
          <a href="${pageContext.request.contextPath}/booklistpage?pageNum=${pageBean.pageNum+1}&pageSize=${pageBean.pageSize}&title=${title}&author=${author}">下一页</a>
          <a href="${pageContext.request.contextPath}/booklistpage?pageNum=${pageBean.pageCount}&pageSize=${pageBean.pageSize}&title=${title}&author=${author}">未页</a>
          [共${pageBean.pageNum}/${pageBean.pageCount}页]
      </div>
</body>
</html>
